<?php
/**
 * Created by PhpStorm.
 * User: 69548
 * Date: 2018/9/19
 * Time: 9:14
 */

namespace app\admin\controller;



use think\Controller;
use \think\Cookie;
use  app\admin\model\ArticleComment as C;

class Articlecomment extends Controller
{
    public function index()
    {
        $model=new C();

        $where='';
        $post= request()->post();
        //分页bug处理
        $temp_page=request()->param('page');
        if(isset($temp_page)){
            //条件从缓存取出
            $post=Cookie::get('postlist');
        }else{
            //把条件写入缓存
            Cookie::set('postlist',$post);
        }
        if (isset($post['comment_id']) and $post['comment_id'] > 0) {
            $where['comment_id'] = $post['comment_id'];
        }
        if (isset($post['comment_status']) and $post['comment_status'] > 0) {
            $where['comment_status'] = $post['comment_status'];
        }
        $da= $model->where($where)->order('comment_id desc')->paginate();
        $this->assign('lie',$da);
        $this->assign('wherelist',$post);
        return $this->fetch();

    }

    public function del(){
        $model=new C();
        $id= input('id');


        $data= $model->del($id);

        if ($data==true){
            return $this->success('删除成功');
        }else{
            return $this->error('删除失败');
        }
    }

    public function review(){

        $model=new C();
        $id= request()->request();


        $data= $model->review($id);

        if ($data==true){
            return $this->success('操作成功');
        }else{
            return $this->error('操作失败');
        }
    }
}